package com.example.administrator.foodrowfresh.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.foodrowfresh.R;
import com.example.administrator.foodrowfresh.models.TimeLimit;
import com.example.administrator.foodrowfresh.superBase.MyBaseAdapter;

import org.xutils.x;

import java.util.List;

/**
 * Created by Administrator on 2016/5/5.
 */
public class FlashSaleAdapter extends MyBaseAdapter {

    private List<TimeLimit.DataBean.FlashSaleBean> flashSaleBeans;
    private LayoutInflater inflater;
    public FlashSaleAdapter(List list, Context mContext) {
        super(list, mContext);
        this.flashSaleBeans=list;
        this.inflater=LayoutInflater.from(mContext);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        FlashSaleViewHolder saleViewHolder=null;
            if (convertView==null)
            {
                convertView= inflater.inflate(R.layout.layout_flashsale_item,parent,false);
                saleViewHolder=new FlashSaleViewHolder(convertView);
                convertView.setTag(saleViewHolder);
            }else
            {
                saleViewHolder= (FlashSaleViewHolder) convertView.getTag();
            }
            saleViewHolder.textViewweitgh.setText("/"+flashSaleBeans.get(position).getWeight());
            saleViewHolder.textViewname.setText(flashSaleBeans.get(position).getProductName());
            saleViewHolder.textViewprice.setText("￥"+flashSaleBeans.get(position).getPeriodMoney());
            x.image().bind(saleViewHolder.textViewicon,flashSaleBeans.get(position).getImage());
        return convertView;
    }
    public class FlashSaleViewHolder
    {
        ImageView textViewicon;
        TextView textViewname;
        TextView textViewprice;
        TextView textViewweitgh;

        public FlashSaleViewHolder(View convertView)
        {
            super();
            textViewicon= (ImageView) convertView.findViewById(R.id.flashsale_icon_item);
            textViewname= (TextView) convertView.findViewById(R.id.flashsale_name);
            textViewprice= (TextView) convertView.findViewById(R.id.flashsale_price);
            textViewweitgh= (TextView) convertView.findViewById(R.id.flashsale_weitgh);
        }
    }
}
